#pragma once

#include "TypeOfBase.h"
#include "Reflection/Class.h"



struct WHENGINE_API SSubclassOfBase : public STypeOfBase
{
public:

    SSubclassOfBase(CClass* InClass)
        : STypeOfBase(InClass)
    {
    }

    CClass * Get() const
    {
        assert(Type && "subclass of not set, should set in constructor");
        return reinterpret_cast<CClass *>(Type);
    }



    bool operator==(const SSubclassOfBase& Other) const
    {
        return Type == Other.Type;
    }

    uint64_t GetHashCode() const
    {
        return reinterpret_cast<uint64_t>(Type);
    }

};
static_assert(sizeof(SSubclassOfBase) == sizeof(STypeOfBase), "subclass of base size mismatch");

template<typename T>
class TSubclassOf : public SSubclassOfBase
{
public:
    TSubclassOf()
    :SSubclassOfBase(T::StaticClass())
    {
    }

    TSubclassOf(CClass* InClass)
    :SSubclassOfBase(InClass)
    {
        assert(InClass->IsA(T::StaticClass())); 
    }

    virtual void SetClass(CClass * InClass) override
    {
        if(InClass)
        {
            assert(InClass->IsA(T::StaticClass()));
        }
        Type = InClass;
    }

};


